package com.hunan.api.catv.entity.enums;

import com.google.gson.JsonObject;

import java.util.LinkedList;
import java.util.List;

/**
 * 栏目类型: 1短视频 2点播 3电视台 4 慢直播  5活动
 * TODO app接口写好后加 url
 */
public enum ColumnEnum {

    recommend(0, "精选", "/api/index/list", "/api/index/top"),
    news(1, "短视频", "/api/news/list", ""),
    video(2, "点播", "", ""),
    tv(3, "电视台", "/api/live/list", ""),
    live(4, "慢直播", "/api/live/list", ""),
    activity(5, "活动", "/api/activity/list", "");

    private final Integer code;

    private final String value;

    private final String url;

    private final String top;

    public static List<Object> columnList = new LinkedList<Object>();


    ColumnEnum(Integer code, String value, String url, String top) {
        this.code = code;
        this.value = value;
        this.url = url;
        this.top = top;
    }

    public String getTop() {
        return top;
    }


    public Integer getCode() {
        return code;
    }

    public String getValue() {
        return value;
    }

    public String getUrl() {
        return url;
    }

    static {
        ColumnEnum[] rcs = ColumnEnum.values();
        for (ColumnEnum rc : rcs) {
            if (rc.code.equals(0)) {
                continue;
            }
            JsonObject column = new JsonObject();
            column.addProperty("id", rc.getCode());
            column.addProperty("name", rc.getValue());
            columnList.add(column);
        }
    }

    public static ColumnEnum getResult(int code) {
        ColumnEnum[] rcs = ColumnEnum.values();
        for (ColumnEnum rc : rcs) {
            if (rc.getCode() == code) {
                return rc;
            }
        }
        return null;
    }

}
